﻿
@{
    var lstUser = ViewBag.lstUser;
    int columns = 2;
    var rowsMenu = lstUser.Items.Count % columns == 0 ? lstUser.Items.Count / columns :
                    (lstUser.Items.Count + (columns - (lstUser.Items.Count % columns))) / columns;
    int index = 0;
}

@if (!(lstUser.Items.Count == 0 || lstUser == null))
{
    <table class="tbl-list" style="margin: 10px auto;width:500px;">

        @for (int i = 0; i < rowsMenu; i++)
        {
            <tr>
                @for (int j = 0; j < columns; j++)
                {
                    index = columns * i + j;
                    if (index >= lstUser.Items.Count) { break; }
                    <td style="width:50%" class="td-onclick">
                        <div id="checkboxUserChecked">
                            <input type="checkbox" name="@lstUser.Items[index].Value" />&nbsp;&nbsp;&nbsp;@lstUser.Items[index].Text
                        </div>
                    </td>
                }
                @if (i == rowsMenu - 1)
                {
                    if (lstUser.Items.Count % columns != 0)
                    {
                        int cellCount = columns - (lstUser.Items.Count % columns);
                        for (int k = 0; k < cellCount; k++)
                        {
                            <td></td>
                        }
                    }
                    
                }
            </tr>
        }
    </table>
}
else
{
    <div style="padding-top:15px; text-align:center;">
        <span class="field-validation-error" >Không tìm thấy kết quả nào</span>
    </div>
}
